home *** CD-ROM | disk | FTP | other *** search
- #include "defs.h"
- #include "Prefs.h"
- #include "embedded resources.h"
-
- enum { // enabled DITL items
- i_OK = 1,
- i_cancel,
- i_return,
- i_space,
- i_window,
- i_everywhere,
- i_selected_rect,
- i_fake_activate
- };
-
- void Configure_dialog( void )
- {
- ControlHandle return_h, space_h, window_h, everywhere_h, selected_h;
- ControlHandle fake_activate_h;
- DialogPtr dp;
- Rect box;
- short itype;
- Boolean spaces_temp;
- char copy_mode_temp;
- Boolean fake_activate_temp;
- short item_hit;
- GrafPtr save_port;
- short save_resfile;
-
- GetPort( &save_port );
- save_resfile = CurResFile();
- UseResFile( pref_resfile );
-
- dp = GetNewDialog( DLOG_ID, NIL, (WindowPtr)-1L );
- if (dp != NIL)
- {
- /* Get handles to the radio buttons. */
- GetDItem( dp, i_return, &itype, (Handle *)&return_h, &box );
- GetDItem( dp, i_space, &itype, (Handle *)&space_h, &box );
- GetDItem( dp, i_window, &itype, (Handle *)&window_h, &box );
- GetDItem( dp, i_everywhere, &itype, (Handle *)&everywhere_h, &box );
- GetDItem( dp, i_selected_rect, &itype, (Handle *)&selected_h, &box );
- GetDItem( dp, i_fake_activate, &itype, (Handle *)&fake_activate_h, &box );
-
- /* Initialize the values of the radio buttons. */
- spaces_temp = spaces;
- copy_mode_temp = copy_mode;
- fake_activate_temp = fake_activate;
- SetCtlValue( return_h, !spaces_temp );
- SetCtlValue( space_h, spaces_temp );
- SetCtlValue( window_h, copy_mode_temp == c_window );
- SetCtlValue( everywhere_h, copy_mode_temp == c_all );
- SetCtlValue( selected_h, copy_mode_temp == c_selected );
- SetCtlValue( fake_activate_h, fake_activate );
-
- /* Show the window and go... */
- ShowWindow( dp );
- SetPort( dp );
- do {
- ModalDialog( NIL, &item_hit );
- if ( ((item_hit == i_return) && spaces_temp)
- || ((item_hit == i_space) && !spaces_temp) )
- {
- spaces_temp = !spaces_temp;
- SetCtlValue( return_h, !spaces_temp );
- SetCtlValue( space_h, spaces_temp );
- }
- else if ( ((item_hit == i_window) && (copy_mode_temp != c_window))
- || ((item_hit == i_everywhere) && (copy_mode_temp != c_all))
- || ((item_hit == i_selected_rect) && (copy_mode_temp != c_selected)) )
- {
- if (item_hit == i_window)
- copy_mode_temp = c_window;
- else if (item_hit == i_everywhere)
- copy_mode_temp = c_all;
- else
- copy_mode_temp = c_selected;
- SetCtlValue( window_h, copy_mode_temp == c_window );
- SetCtlValue( everywhere_h, copy_mode_temp == c_all );
- SetCtlValue( selected_h, copy_mode_temp == c_selected );
- }
- else if (item_hit == i_fake_activate)
- {
- fake_activate_temp = !fake_activate_temp;
- SetCtlValue( fake_activate_h, fake_activate_temp );
- }
- } while ( (item_hit != i_OK) && (item_hit != i_cancel) );
- DisposDialog( dp );
-
- /* Any change? */
- if ( (item_hit == i_OK) &&
- ( (spaces_temp != spaces) || (copy_mode_temp != copy_mode) ||
- (fake_activate_temp != fake_activate) ) )
- {
- copy_mode = copy_mode_temp;
- spaces = spaces_temp;
- fake_activate = fake_activate_temp;
- Set_prefs();
- }
- }
- SetPort( save_port );
- UseResFile( save_resfile );
- }